package com.hanamaki.oop.demo05;

/**
 * 封装：就是属性的私有
 */

/**
 * 保护程序的安全性，保护数据
 * 隐藏代码的实现细节
 * 统一接口
 * 维护性会增高
 */
public class Student {

    // 属性
    private int stuId;
    private String stuName;

    private char sex;
    private int age;

    // 属性私有后，要提供能够操作属性的方法   alt + insert


    public int getStuId() {
        return stuId;
    }

    public void setStuId(int stuId) {
        this.stuId = stuId;
    }

    public String getStuName() {
        return stuName;
    }

    public void setStuName(String stuName) {
        this.stuName = stuName;
    }

    public char getSex() {
        return sex;
    }

    public void setSex(char sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if (age > 130 || age < 0) {
            this.age = 20;
        } else
            this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "stuId=" + stuId +
                ", stuName='" + stuName + '\'' +
                ", sex=" + sex +
                ", age=" + age +
                '}';
    }
}
